/**************************************************************************/
/*                                                                        */
/* Copyright (c) SinoEmbed Technology Co.,Ltd.           */
/*  */
/*                                                                        */
/*                                                                        */
/*    created:    2012-8-15                                            */ 
/*    filename:                                             */ 
/*    author:     Derek Huang                                                  */  
/*    purpose:                                                            */ 
/*                                                                        */
/* ************************************************************************/
#include "FileBrowserApp.h"
#include "FileBrowserWnd.h"
//#include "Parameter.h"
//#include "CommFunc.h"

//CFileBrowserApp FileBrowserApp;
//#define VIDEOBROWSER_XML_SKIN_PATH	_T("\\ResidentFlash2\\IntApp\\Skins\\VideoFileBrowser.xml")

//#define VIDEOBROWSER_XML_SKIN_PATH	_T("\\Nand\\IntApp\\Skins\\VideoFileBrowser.xml")
//#define VIDEOBROWSER_XML_SKIN_PATH	_T("\\SDMMC\\IntApp\\Skins\\VideoFileBrowser.xml")
//#define VIDEOBROWSER_XML_SKIN_PATH	_T("\\ResidentFlash2\\IntApp30\\Skins\\VideoFileBrowser.xml")
//extern void GetRectFromString(	TCHAR* strRect,  RECT *rect);
extern TCHAR g_RootPath[128];

CFileBrowserApp::CFileBrowserApp()
{
	m_pMainWin = NULL;
}

CFileBrowserApp::~CFileBrowserApp()
{
	CoUninitialize();	
}
BOOL CFileBrowserApp::Init(BOOL bIsHide)
{

	CoInitializeEx(NULL, COINIT_MULTITHREADED );
//jdhuang 20120815
/*
	CXmlParser*        xmlParser;
	xmlParser = (CXmlParser*)CreateSkObject();
	xmlParser->Load(VIDEOBROWSER_XML_SKIN_PATH);
printf("1\r\n0");
	TCHAR  buffer[64];
	int  nLength = 64;
	int  dwResBG = 0;
	LONG lRet;
	RECT rtVideo;

	lRet = xmlParser->GetNodeAttrValue(L"Back", L"RECT", buffer, nLength);   
	GetRectFromString(buffer, &rtVideo);
	xmlParser->Release();
*/
	int cx,cy;
	cx = GetSystemMetrics(SM_CXSCREEN);
	cy = GetSystemMetrics(SM_CYSCREEN);
	m_pMainWin = new CFileBrowserWnd(g_RootPath, DISC_ONE);
	if( m_pMainWin )
	{
		if(m_pMainWin->Create(0, 0, cx, cy, 0, 0, 0, 0))
		{
			if(bIsHide)
				m_pMainWin->Show();
			else
				m_pMainWin->Show(false);
			return TRUE;
		}
		else
		{
			return FALSE;
		}	
	}
	else
	{
		return FALSE;
	}
	return CMzApp::Init();
	
}

int CFileBrowserApp::Done()
{
//	ImagingHelper::ClearCachedImages();
//	ImagingHelper::UnLoadImagingFactory();
//	FreeMzResModule();
//	FontHelper::ClearCachedFonts();
//	ClearCachedRoundMaskBitmaps();
//	UnLoadGradientBgResource();
	return 1;
}
